package apple.core;
import java.util.HashMap;
import java.util.Map;

public class Font {

	public static final int HORIZONTAL_PIXELS_PER_CHARACTER = 7;

	public static final int VERTICAL_PIXELS_PER_CHARACTER = 8;

	/*
	 * For each character in the map, its int[] contains a value for each
	 * foreground pixel required to render the character. These values specify
	 * the location of the pixel in the character's 7x8 grid, where the pixels
	 * in the grid are numbered from 0 to 55, rows ordered sequentially from top
	 * to bottom and columns ordered from left to right.
	 */
	private static final Map<Character, int[]> characterPixels = new HashMap<Character, int[]>();

	static {
		int[] pixels;

		// <space>
		pixels = new int[] {};
		characterPixels.put(' ', pixels);

		// !
		pixels = new int[] { 3, 10, 17, 24, 31, 45 };
		characterPixels.put('!', pixels);

		// "
		pixels = new int[] { 2, 4, 9, 11, 16, 18 };
		characterPixels.put('"', pixels);

		// #
		pixels = new int[] { 2, 4, 9, 11, 15, 16, 17, 18, 19, 23, 25, 29, 30,
				31, 32, 33, 37, 39, 44, 46 };
		characterPixels.put('#', pixels);

		// $
		pixels = new int[] { 3, 9, 10, 11, 12, 15, 17, 23, 24, 25, 31, 33, 36,
				37, 38, 39, 45 };
		characterPixels.put('$', pixels);

		// %
		pixels = new int[] { 1, 2, 8, 9, 12, 18, 24, 30, 36, 39, 40, 46, 47 };
		characterPixels.put('%', pixels);

		// &
		pixels = new int[] { 2, 8, 10, 15, 17, 23, 29, 31, 33, 36, 39, 44, 45,
				47 };
		characterPixels.put('&', pixels);

		// '
		pixels = new int[] { 3, 10, 17 };
		characterPixels.put('\'', pixels);

		// (
		pixels = new int[] { 3, 9, 15, 22, 29, 37, 45 };
		characterPixels.put('(', pixels);

		// )
		pixels = new int[] { 3, 11, 19, 26, 33, 39, 45 };
		characterPixels.put(')', pixels);

		// *
		pixels = new int[] { 3, 8, 10, 12, 16, 17, 18, 24, 30, 31, 32, 36, 38,
				40, 45 };
		characterPixels.put('*', pixels);

		// +
		pixels = new int[] { 10, 17, 22, 23, 24, 25, 26, 31, 38 };
		characterPixels.put('+', pixels);

		// ,
		pixels = new int[] { 31, 38, 44 };
		characterPixels.put(',', pixels);

		// -
		pixels = new int[] { 15, 16, 17, 18, 19 };
		characterPixels.put('-', pixels);

		// .
		pixels = new int[] { 45 };
		characterPixels.put('.', pixels);

		// /
		pixels = new int[] { 12, 18, 24, 30, 36 };
		characterPixels.put('/', pixels);

		// 0
		pixels = new int[] { 2, 3, 4, 8, 12, 15, 18, 19, 22, 24, 26, 29, 30,
				33, 36, 40, 44, 45, 46 };
		characterPixels.put('0', pixels);

		// 1
		pixels = new int[] { 3, 9, 10, 17, 24, 31, 38, 44, 45, 46 };
		characterPixels.put('1', pixels);

		// 2
		pixels = new int[] { 2, 3, 4, 8, 12, 19, 24, 25, 30, 36, 43, 44, 45,
				46, 47 };
		characterPixels.put('2', pixels);

		// 3
		pixels = new int[] { 1, 2, 3, 4, 5, 12, 18, 24, 25, 33, 36, 40, 44, 45,
				46 };
		characterPixels.put('3', pixels);

		// 4
		pixels = new int[] { 4, 10, 11, 16, 18, 22, 25, 29, 30, 31, 32, 33, 39,
				46 };
		characterPixels.put('4', pixels);

		// 5
		pixels = new int[] { 1, 2, 3, 4, 5, 8, 15, 16, 17, 18, 26, 33, 36, 40,
				44, 45, 46 };
		characterPixels.put('5', pixels);

		// 6
		pixels = new int[] { 3, 4, 5, 9, 15, 22, 23, 24, 25, 29, 33, 36, 40,
				44, 45, 46 };
		characterPixels.put('6', pixels);

		// 7
		pixels = new int[] { 1, 2, 3, 4, 5, 12, 18, 24, 30, 37, 44 };
		characterPixels.put('7', pixels);

		// 8
		pixels = new int[] { 2, 3, 4, 8, 12, 15, 19, 23, 24, 25, 29, 33, 36,
				40, 44, 45, 46 };
		characterPixels.put('8', pixels);

		// 9
		pixels = new int[] { 2, 3, 4, 8, 12, 15, 19, 23, 24, 25, 26, 33, 39,
				43, 44, 45 };
		characterPixels.put('9', pixels);

		// :
		pixels = new int[] { 17, 31 };
		characterPixels.put(':', pixels);

		// ;
		pixels = new int[] { 17, 31, 38, 44 };
		characterPixels.put(';', pixels);

		// <
		pixels = new int[] { 4, 10, 16, 22, 30, 38, 46 };
		characterPixels.put('<', pixels);

		// =
		pixels = new int[] { 8, 9, 10, 11, 12, 22, 23, 24, 25, 26 };
		characterPixels.put('=', pixels);

		// >
		pixels = new int[] { 2, 10, 18, 26, 32, 38, 44 };
		characterPixels.put('>', pixels);

		// ?
		pixels = new int[] { 2, 3, 4, 8, 12, 18, 24, 31, 45 };
		characterPixels.put('?', pixels);

		// @
		pixels = new int[] { 2, 3, 4, 8, 12, 15, 17, 19, 22, 24, 25, 26, 29,
				31, 32, 36, 44, 45, 46, 47 };
		characterPixels.put('@', pixels);

		// A
		pixels = new int[] { 3, 9, 11, 15, 19, 22, 26, 29, 30, 31, 32, 33, 36,
				40, 43, 47 };
		characterPixels.put('A', pixels);

		// B
		pixels = new int[] { 1, 2, 3, 4, 8, 12, 15, 19, 22, 23, 24, 25, 29, 33,
				36, 40, 43, 44, 45, 46 };
		characterPixels.put('B', pixels);

		// C
		pixels = new int[] { 2, 3, 4, 8, 12, 15, 22, 29, 36, 40, 44, 45, 46 };
		characterPixels.put('C', pixels);

		// D
		pixels = new int[] { 1, 2, 3, 4, 8, 12, 15, 19, 22, 26, 29, 33, 36, 40,
				43, 44, 45, 46 };
		characterPixels.put('D', pixels);

		// E
		pixels = new int[] { 1, 2, 3, 4, 5, 8, 15, 22, 23, 24, 25, 29, 36, 43,
				44, 45, 46, 47 };
		characterPixels.put('E', pixels);

		// F
		pixels = new int[] { 1, 2, 3, 4, 5, 8, 15, 22, 23, 24, 25, 29, 36, 43 };
		characterPixels.put('F', pixels);

		// G
		pixels = new int[] { 2, 3, 4, 5, 8, 15, 22, 29, 32, 33, 36, 40, 44, 45,
				46, 47 };
		characterPixels.put('G', pixels);

		// H
		pixels = new int[] { 1, 5, 8, 12, 15, 19, 22, 23, 24, 25, 26, 29, 33,
				36, 40, 43, 47 };
		characterPixels.put('H', pixels);

		// I
		pixels = new int[] { 2, 3, 4, 10, 17, 24, 31, 38, 44, 45, 46 };
		characterPixels.put('I', pixels);

		// J
		pixels = new int[] { 5, 12, 19, 26, 33, 36, 40, 44, 45, 46 };
		characterPixels.put('J', pixels);

		// K
		pixels = new int[] { 1, 5, 8, 11, 15, 17, 22, 23, 29, 31, 36, 39, 43,
				47 };
		characterPixels.put('K', pixels);

		// L
		pixels = new int[] { 1, 8, 15, 22, 29, 36, 43, 44, 45, 46, 47 };
		characterPixels.put('L', pixels);

		// M
		pixels = new int[] { 1, 5, 8, 9, 11, 12, 15, 17, 19, 22, 26, 29, 33,
				36, 40, 43, 47 };
		characterPixels.put('M', pixels);

		// N
		pixels = new int[] { 1, 5, 8, 12, 15, 16, 19, 22, 24, 26, 29, 32, 33,
				36, 40, 43, 47 };
		characterPixels.put('N', pixels);

		// O
		pixels = new int[] { 2, 3, 4, 8, 12, 15, 19, 22, 26, 29, 33, 36, 40,
				44, 45, 46 };
		characterPixels.put('O', pixels);

		// P
		pixels = new int[] { 1, 2, 3, 4, 8, 12, 15, 19, 22, 23, 24, 25, 29, 36,
				43 };
		characterPixels.put('P', pixels);

		// Q
		pixels = new int[] { 2, 3, 4, 8, 12, 15, 19, 22, 26, 29, 31, 33, 36,
				39, 44, 45, 47 };
		characterPixels.put('Q', pixels);

		// R
		pixels = new int[] { 1, 2, 3, 4, 8, 12, 15, 19, 22, 23, 24, 25, 29, 31,
				36, 39, 43, 47 };
		characterPixels.put('R', pixels);

		// S
		pixels = new int[] { 2, 3, 4, 8, 12, 15, 23, 24, 25, 33, 36, 40, 44,
				45, 46 };
		characterPixels.put('S', pixels);

		// T
		pixels = new int[] { 1, 2, 3, 4, 5, 10, 17, 24, 31, 38, 45 };
		characterPixels.put('T', pixels);

		// U
		pixels = new int[] { 1, 5, 8, 12, 15, 19, 22, 26, 29, 33, 36, 40, 44,
				45, 46 };
		characterPixels.put('U', pixels);

		// V
		pixels = new int[] { 1, 5, 8, 12, 15, 19, 22, 26, 29, 33, 37, 39, 45 };
		characterPixels.put('V', pixels);

		// W
		pixels = new int[] { 1, 5, 8, 12, 15, 19, 22, 24, 26, 29, 31, 33, 36,
				37, 39, 40, 43, 47 };
		characterPixels.put('W', pixels);

		// X
		pixels = new int[] { 1, 5, 8, 12, 16, 18, 24, 30, 32, 36, 40, 43, 47 };
		characterPixels.put('X', pixels);

		// Y
		pixels = new int[] { 1, 5, 8, 12, 16, 18, 24, 31, 38, 45 };
		characterPixels.put('Y', pixels);

		// Z
		pixels = new int[] { 1, 2, 3, 4, 5, 12, 18, 24, 30, 36, 43, 44, 45, 46,
				47 };
		characterPixels.put('Z', pixels);

		// [
		pixels = new int[] { 1, 2, 3, 4, 5, 8, 9, 15, 16, 22, 23, 29, 30, 36,
				37, 43, 44, 45, 46, 47 };
		characterPixels.put('[', pixels);

		// \
		pixels = new int[] { 8, 16, 24, 32, 40 };
		characterPixels.put('\\', pixels);

		// ]
		pixels = new int[] { 1, 2, 3, 4, 5, 11, 12, 18, 19, 25, 26, 32, 33, 39,
				40, 43, 44, 45, 46, 47 };
		characterPixels.put(']', pixels);

		// ^
		pixels = new int[] { 17, 23, 25, 29, 33 };
		characterPixels.put('^', pixels);

		// _
		pixels = new int[] { 49, 50, 51, 52, 53, 54, 55 };
		characterPixels.put('_', pixels);

		// `
		pixels = new int[] { 1, 9, 17 };
		characterPixels.put('`', pixels);

		// |
		pixels = new int[] { 3, 10, 17, 24, 31, 38, 45 };
		characterPixels.put('|', pixels);

		// ~
		pixels = new int[] { 2, 3, 5, 8, 10, 11 };
		characterPixels.put('~', pixels);

	}

	public static int[] getCharacterPixels(char character) {
		return characterPixels.get(character);
	}
}
